# -*- coding: utf-8 -*-

from django.db import models
from core.models import CoreModel, table_prefix


class Dept(CoreModel):
    name = models.CharField(max_length=64, verbose_name="部门名称")
    owner = models.CharField(
        null=True, blank=True, max_length=32, verbose_name="负责人"
    )
    phone = models.CharField(
        null=True, blank=True, max_length=32, verbose_name="联系电话"
    )
    email = models.EmailField(null=True, blank=True, max_length=32, verbose_name="邮箱")
    parent = models.ForeignKey(
        null=True,
        blank=True,
        to="Dept",
        default=None,
        on_delete=models.CASCADE,
        db_constraint=False,
        verbose_name="上级部门",
    )

    class Meta:
        db_table = table_prefix + "system_dept"
        verbose_name = "部门管理"
        verbose_name_plural = verbose_name
        ordering = ("sort",)
